
public class Line extends InfiniteLine implements Shape {
	private Point e1, e2; // Endpoints

	public Line(Point p1, Point p2) {
		super(p1, p2);
		
		// Make sure that e1 is never "to the right of" e2
		if(p1.getX() > p2.getX()) {
			this.e1 = p2;
			this.e2 = p1;
		} else {
			this.e1 = p1;
			this.e2 = p2;
		}
	}
	
	/** Setters **/
	public void setEnd1(Point e1) {
		this.e1 = e1;
	}
	public void setEnd2(Point e2) {
		this.e2 = e2;
	}
	
	/** Getters **/
	public Point getEnd1() {
		return this.e1;
	}
	public Point getEnd2() {
		return this.e2;
	}
	
	// The area between this line and the X-axis from e1 to e2
	public double integral() {
		return integral(this.e1, this.e2);
	}
	
	public String toString() {
		return super.toString() + " ["+ e1 +", "+ e2 +"]";
	}
}
